package com.chf.inits;

import com.chf.items.*;
import com.chf.mods.FirstMod;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Rarity;
import net.minecraftforge.common.ForgeSpawnEggItem;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

/**
 * 注册自定义东西
 *
 * @author niooooo
 */
public class Items {

    // ================================================= 注册物品 ================================================= //

    public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, FirstMod.MOD_ID);

    /**
     * 创建物品
     * <ol>
     *     <li> 第一个参数表示默认名称（item.${mod_id}.${默认名称}） </li>
     *     <li> 第二个参数表示创建的类型（可以自定义实现类型类重写方法功能） </li>
     *     <li> 名称默认从路径（classpath:assets/${mod_id}/lang/）下读取对应语言 </li>
     *     <li> version 1.21.6：如果配置了 overrideDescription() 方法，则不管什么语言环境下仅展示该名称 </li>
     * </ol>
     */
    public static final RegistryObject<Item> FIRST_ITEM = ITEMS.register(
            "first_item",
            () -> new FirstItem(new Item.Properties()));

    public static final RegistryObject<Item> RED_STONE_SWORD = ITEMS.register(
            "red_stone_sword",
            () -> new RedStoneSwordItem(new Item.Properties()
                    // 史诗品质
                    .rarity(Rarity.RARE)
                    // 耐久度
                    .durability(500)));

    public static final RegistryObject<Item> OBSIDIAN_SWORD = ITEMS.register(
            "obsidian_sword",
            () -> new ObsidianSword(
                    1, 4.2F,
                    new Item.Properties().durability(100)));

    public static final RegistryObject<Item> OBSIDIAN_PICKAXE = ITEMS.register(
            "obsidian_pickaxe",
            () -> new ObsidianPickaxe(
                    1, 4.2F,
                    new Item.Properties().durability(100)));

    public static final RegistryObject<Item> OBSIDIAN_AXE = ITEMS.register(
            "obsidian_axe",
            () -> new ObsidianAxe(
                    1, 4.2F,
                    new Item.Properties().durability(100)));

    // ================================================= 注册方块的物品形式 ================================================= //

    public static final RegistryObject<Item> FIRST_BLOCK = ITEMS.register("first_block",
            () -> new BlockItem(FirstModBlocks.FIRST_BLOCK.get(), new Item.Properties()));

    // ================================================= 注册自定义僵尸刷怪蛋 ================================================= //

    public static final RegistryObject<Item> ZOMBIE_PLUS_SPAWN_EGG = ITEMS.register(
            "zombie_plus_spawn_egg",
            () -> new ForgeSpawnEggItem(
                    FirstEntityType.ZOMBIE_PLUS,
                    // 主要颜色（深绿色）
                    0x0F4F00,
                    // 次要颜色（灰色）
                    0x8D8D8D,
                    new Item.Properties()
            )
    );
}
